export const types = {
    SET_OPENID: "user/SET_OPENID",
    SET_PHONE: "user/SET_PHONE",
    SET_MID: "user/SET_MID",
    SET_MODETYPE: "user/SET_MODETYPE",
    SET_ID: "user/SET_ID",
    SET_DEVICE_STATUS: "user/SET_DEVICE_STATUS",
};
export default {
    namespaced: true,
    state: {
        id: "",
        openid: 0,
        phone: "",
        mid: "",
        modeType: "",
        isLogin: false,
        deviceStatus: 0,
    },
    mutations: {
        [types.SET_OPENID](state, openid) {
            state.openid = openid;
        },
        [types.SET_PHONE](state, phone) {
            state.phone = phone;
            state.isLogin = !!phone;
        },
        [types.SET_MID](state, mid) {
            state.mid = mid;
        },
        [types.SET_MODETYPE](state, modeType) {
            state.modeType = modeType;
        },
        [types.SET_ID](state, id) {
            state.id = id;
        },
        [types.SET_DEVICE_STATUS](state, deviceStatus) {
            state.deviceStatus = deviceStatus;
        },
    },
    actions: {
        setOpenid({ commit }, openid) {
            commit(types.SET_OPENID, openid);
        },
        setPhone({ commit }, phone) {
            commit(types.SET_PHONE, phone);
        },
        setMid({ commit }, mid) {
            commit(types.SET_MID, mid);
        },
        setModeType({ commit }, modeType) {
            commit(types.SET_MODETYPE, modeType);
        },
        setId({ commit }, id) {
            commit(types.SET_ID, id);
        },
        setDeviceStatus({ commit }, deviceStatus) {
            commit(types.SET_DEVICE_STATUS, deviceStatus);
        },
    },
};
